package com.hndfsj.common.web;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hndfsj.common.domain.TokenModel;
import com.hndfsj.common.service.ITokenService;
import com.hndfsj.framework.common.MReturnObject;
import com.hndfsj.framework.controller.base.BaseRestJSONController;

@Controller
@RequestMapping("/tk")
public class TokenController extends BaseRestJSONController {
	@Resource
	private ITokenService tokenService;

	@RequestMapping("/get/token")
	public @ResponseBody MReturnObject getToken(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		TokenModel model = tokenService.createToken(getCurrentMember().getUsername());
		model.setUsername("");
		return new MReturnObject(MReturnObject.SUCCESS, "", model);
	}

}
